home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / database / eb106a.zip / PACK1.PRG / EB5.REP (.txt) < prev    next >
PC-File  |  1996-04-02  |  40KB  |  726 lines

  1.           
  2.           EASY BASE NETWORKING GUIDE                 Contents
  3.           
  4.           Introduction                               Page   1
  5.           Batch Starting                             Page   3
  6.           Clearing Locks                             Page   4
  7.           Configuration                              Page   6
  8.           Development Work                           Page   7
  9.           File Open On Server                        Page   9
  10.           Lock Directory                             Page  10
  11.           Numbering Records                          Page  11
  12.           Private Keyword                            Page  12
  13.           Protective Locking                         Page  13
  14.           Self Locking Loops                         Page  16
  15.           Strategic Locking                          Page  17
  16.           Terminal Number Val.                       Page  18
  17.           Unique Entries                             Page  19
  18. ................................................................................
  19.      Introduction                                
  20. Introduction
  21.      Easy Base Networker has been designed to make the creation of
  22.      multi user data management systems as simple as possible. To do
  23.      this it incorporates automatic locking and privatisation
  24.      routines. With a few exceptions, you can create multi user
  25.      systems just as if you were writing for a stand alone PC.
  26.      The few exceptions are, however, important so please read this
  27.      short guide before attempting to convert any single user
  28.      application.
  29.      Because Easy Base is an interpreter, the same program is used
  30.      both for the creation of your application and for running it.
  31.      Only the running routines are multi user. Multiple work
  32.      stations can access the same forms and procedures
  33.      simultaneously only when such forms and procedures are called
  34.      from pre defined user menus. Multiple work stations can access
  35.      the form and procedure design routines (System Menus) provided
  36.      they are each doing design work in different data sub
  37.      directories. No two work stations can access the system menus
  38.      for the same data sub directory at the same time.
  39.      Terminology used in this Guide.
  40.      PUBLIC FILES:
  41.      Files to which all work stations have access. The public files
  42.      are form definition, data and procedure definition files
  43.      together with the network common configuration file.
  44.      PRIVATE FILES:
  45.      Files for which each work station has its own copy. The private
  46.      files are: user menus, terminal configuration, procedure output
  47.      subindex and temporary forms. You can also write to private
  48.      copies of public form definitions for temporary storage by
  49.      using the keyword "Private".
  50.      TERMINAL NUMBER:-
  51.      This is a unique number assigned to each work station logged on
  52.      to Easy Base. The terminal number is used in the naming of the
  53.      work station's private files and for recording which work
  54.      station has placed any access lock.
  55.      SYSTEM LOCKS
  56.      The locks which Easy Base engages to prevent simultaneous
  57.      loading and simultaneous access to the system menus in any one
  58.      data sub directory.
  59.      PROTECIVE LOCKS
  60.      The locks which Easy Base engages to prevent index file
  61.                                 - 1 -
  62. ................................................................................
  63.      Introduction                                
  64. Introduction
  65.      corruption during multiple access.
  66.      STRATEGIC LOCKS
  67.      The locks you set in procedure code when you require a form to
  68.      be locked for non protective reasons.
  69.      Easy Base Networker was developed under Novell Personal
  70.      Netware. It does not, however, contain any Novell specific code
  71.      and should be reliable on any DOS based network system.
  72.      To get started, install Easy Base to a new directory on a
  73.      server. Allocate a drive letter for your work stations to
  74.      reference this directory and set your network software to allow
  75.      unrestricted read and write access to all files in that
  76.      directory and all sub directories under it.
  77.      To log on to Easy Base, three parameters are required. The
  78.      terminal number to use, The data sub directory to operate in
  79.      and a password for either the system menus or a user menu.
  80.      From a work station, change to the drive you have allocated and
  81.      type "EB".
  82.      When you start Easy Base with the command EB you will be asked
  83.      to supply the three parameters which it requires. All three
  84.      parameters can be supplied automatically either by setting them
  85.      in the environment ( Work stations which self boot ) or by
  86.      placing them on the command line. ( See Batch Starting )
  87.      All locking in Easy Base is by "Soft lock". DOS file and record
  88.      locking techniques are not used. With any locking strategy,
  89.      locks can be left engaged if a work station suffers a power
  90.      failure or is switched off without exiting the program. System
  91.      and Access locks which are left engaged after a power failure
  92.      can be cleared by Easy Base or by DOS file erasure.
  93.      (See Clearing Locks )
  94.      Applications written in previous stand alone versions of Easy
  95.      Base can be copied directly to a sub directory of Easy Base
  96.      Networker. However, the pre processed (.PPR) files created by
  97.      Version 9 are NOT compatible with Network V1 and must be erased
  98.      before use. You can erase all .PPR files by selecting
  99.      Relationships from the main system menu.  The system values
  100.      Total Records, Total Copies and Current Record no longer exist.
  101.      Any procedure which uses these values must be changed. They are
  102.      now available as pseudo fields Form.Total Records, Form.Total
  103.      Copies and Form.Record Number.
  104.                                 - 2 -
  105. ................................................................................
  106.      Batch Starting                              
  107. Batch Starting
  108.      You can by pass entering any or all of the sign on parameters
  109.      either by setting them in the environment of the work station
  110.      or by supplying them on the command line.
  111.      To have a work station automatically log on as terminal 1 in
  112.      the sub directory accounts with the password "Fred", add the
  113.      following lines to the work station's Autoexec.Bat file:-
  114.      SET EBT=1
  115.      SET EBD=ACCOUNTS
  116.      SET EBP=FRED
  117.      Or start Easy Base with the command line :-
  118.      EB T=1 D=ACCOUNTS P=FRED
  119.      Any parameters which are not supplied either in the environment
  120.      or on the command line will be asked for on start up.
  121.      If you have set the start up parameters for any given work
  122.      station in the environment and you start Easy Base with
  123.      different parameters on the command line, the parameters on the
  124.      command line override those in the environment.
  125.      If your application has different passwords for different menu
  126.      structures you can set the terminal number and directory and
  127.      leave the user to supply the password.
  128.      If the user has access to different directories then just set
  129.      the terminal number and the user can choose the directory and
  130.      enter the password.
  131.      NOVELL WARNING
  132.      
  133.      If you save a "Login Script" after setting EB environment
  134.      variables and subsequently change the settings in your
  135.      Autoexec.bat file, Novell will swap the setting it saved for
  136.      the new ones whenever you login. Saving a new Login script
  137.      after the change does not rectify the situation. You actually
  138.      have to find the login script file and edit out the old
  139.      environment settings. Under Novell Personal Netware this file
  140.      is called PNWLOGIN.SCR and is stored in a numbered sub
  141.      directory under C:\NWCNTL\MAIL
  142.                                 - 3 -
  143. ................................................................................
  144.      Clearing Locks                              
  145. Clearing Locks
  146.      ACCESS LOCKS
  147.      If a data access lock is left engaged it can be cleared by
  148.      selecting "Clear Access Locks" from the utilities menu. You can
  149.      also make "Clear Access Locks" available on user menus.
  150.      When you run "Clear Access Locks" Easy Base clears all access
  151.      locks in the current data sub directory. Because it clears ALL
  152.      locks in the current directory you should ensure that no other
  153.      work stations currently require locks in place - ie they should
  154.      not be running procedures or adding or modifying records. There
  155.      is no need for them to log out of Easy Base.
  156.      SYSTEM LOCKS
  157.      Easy Base uses two system locks - a loading lock and a System
  158.      Menus lock. Because of the way Easy Base initially loads its
  159.      overlays, no two work stations can load at the same time. When
  160.      a work station attempts to load Easy Base while another work
  161.      station is loading, Easy Base displays the message "Please wait
  162.      another terminal is loading". As soon as the first work station
  163.      has logged on this message will clear and the second will load.
  164.      If the first terminal suffers a power failure while loading,
  165.      this lock will be left engaged. If the loading lock does not
  166.      clear within one minute, The "Please wait" message displayed on
  167.      any other work station which is trying to load is replaced with
  168.      one which allows the user to escape and enter the reset
  169.      command.
  170.      To clear the loading lock type "EB reset" at the command
  171.      prompt.
  172.      Whenever a work station is accessing the system menus for any
  173.      given data sub directory, all other terminals are locked out of
  174.      the system menus in that directory. If a work station is
  175.      powered off without leaving the system menus then this lock
  176.      will be left engaged and no work station will be able to access
  177.      the system menus for that directory. The system menu lock is
  178.      also cleared by typing "EB reset" at the command prompt.
  179.      WARNING
  180.      It is essential to your data integrity that no two work
  181.      stations log in to Easy Base with the same terminal number. To
  182.      prevent this Easy Base maintains a log of which terminal
  183.      numbers are in use. This log is erased when you issue the
  184.      command "EB reset". If one or more terminals are logged on to
  185.      Easy Base and another issues the command "EB reset" then it
  186.      will be able to log on with a terminal number which is already
  187.      in use. You must prevent this as the two work stations with the
  188.                                 - 4 -
  189. ................................................................................
  190.      Clearing Locks                              
  191. Clearing Locks
  192.      same terminal number will overwrite each others private files
  193.      and ignore each others data access locks with unpredictable
  194.      results.
  195.      If you have arranged for each work station to supply its
  196.      parameters from the environment or from the command line in a
  197.      batch start this is not a problem, but if you allow work
  198.      station operators to choose their terminal number it is.
  199.      To be absolutely sure, you should ensure that all work stations
  200.      exit Easy Base before issuing the "EB Reset" command and log
  201.      back in after it.
  202.      DOS LOCK CLEARING
  203.      All Easy Base locks can be cleared manually by erasing the
  204.      locking files. The locking files are:-
  205.      Loading Lock         EB.LOD        Easy Base Directory
  206.      System Menus Lock    EB.LOG        Easy Base Directory
  207.      Directory Lock       DIR.LOC       Data Directories
  208.      Form Locks           Base(No).LOC  Data Directories
  209.                                 - 5 -
  210. ................................................................................
  211.      Configuration                               
  212. Configuration
  213.      The utilities Install Printer, Options, Screen Colours and Set
  214.      Paper Length described in the programmers reference are
  215.      combined under "Configuration" on the main menu in the network
  216.      version of Easy Base.  You can also add configuration to a user
  217.      menu.
  218.      Apart from date and numeric formatting, all configuration items
  219.      are private to the terminal being configured. You can therefore
  220.      install different printers on different workstations. When you
  221.      install a printer in Easy Base you only have the option to send
  222.      output to LPT1 or LPT2. When you select an LPT port the output
  223.      will be sent either to a printer connected to that port or to a
  224.      network printer that has been mapped to it by your network
  225.      software.
  226.      CAUTION:
  227.      Novell netware reports three LPT ports on all workstations even
  228.      if they only physically have one. If you set output to LPT2 and
  229.      your workstation has no physical LPT2 and no network printer
  230.      has been mapped to LPT2 then Easy Base will hang up when you
  231.      try to print.
  232.      When you change the network common items, date and numeric
  233.      format. They only take effect on other workstations from the
  234.      next time they log in.
  235.                                 - 6 -
  236. ................................................................................
  237.      Development Work                            
  238. Development Work
  239.      When you are doing development work from the system menus there
  240.      should not be any other operator accessing forms or procedures
  241.      in the data directory you are working in. This does not mean
  242.      that you cannot have a second workstation accessing that
  243.      directory under your control. It is in fact preferable to have
  244.      a second workstation for testing purposes. There are aspects of
  245.      design work that Easy Base does not and in some cases cannot
  246.      provide locking for. This section will explain how to avoid
  247.      conflicts.
  248.      The only system operations which are fully protected are Data
  249.      entry from the system menus and packing forms. You can perform
  250.      these operations safely even when other operators are active.
  251.      Whatever system operation you perform, there will be no
  252.      conflict if the other active workstation/s are at rest
  253.      displaying a user menu.
  254.      To make and test modifications to an application, provide
  255.      access to the system menus from your user menu and start your
  256.      application on the user menu for both workstations. One
  257.      workstation can then access the system menus while the other
  258.      remains on the user menu.
  259.      After modifying a form or procedure you can then escape to the
  260.      user menu and test the modification in a multi user
  261.      environment.
  262.      Modifications to forms, relationships and procedures are
  263.      effective immediately.  Modifications to User Menus, Vat rates
  264.      and network common configuration items take effect the next
  265.      time a workstation logs on or changes directory.
  266.      If, for example, you change your user menu structure then you
  267.      must select Change data directory and select the same directory
  268.      again before it is displayed.
  269.      If your application is in constant use, you can minimize down
  270.      time by making and testing your modifications in a spare
  271.      directory with a copy of the App. Once you are happy, other
  272.      users only have to be shut down while you make the
  273.      modifications in the live directory and not while you do your
  274.      testing.
  275.      If you absolutely have to make modifications without shutting
  276.      down other workstations then there is only one operation which
  277.      can actually corrupt your data. That is if you modify a form
  278.      such that its record length changes. You MUST NOT do this while
  279.      any other workstation is in data entry to that form or is
  280.      running a procedure which updates that form. The other work
  281.      station will continue using the old record length and corrupt
  282.      the data file.  All other operations may or may not cause
  283.                                 - 7 -
  284. ................................................................................
  285.      Development Work                            
  286. Development Work
  287.      spurious system errors on either your workstation or one of the
  288.      others but will not normally affect data.
  289.      Whenever you add modify or delete forms, procedures,
  290.      relationships, choice lists or user menus Easy Base erases and
  291.      re writes the definition file and the form, procedure or choice
  292.      list directory file. Any workstation which attempts to read
  293.      from a file between the erase and re write will crash, and your
  294.      workstation will crash if it actions the erase while another
  295.      workstation has the file open.
  296.                                 - 8 -
  297. ................................................................................
  298.      File Open on Server                         
  299. File Open on Server
  300.      If a workstation fails and it had files open at the time, then
  301.      your network server will prevent any other workstation from
  302.      erasing those files before the failed workstation logs back in
  303.      to the network.
  304.      There are several processes in Easy Base which erase files.
  305.      These are, packing, the procedure commands "clear records from"
  306.      and "rename temp as" as well as form, relationship and
  307.      procedure modifications from the system menus.
  308.      If any workstation suffers a power failure while accessing Easy
  309.      Base you should re start it and log back on to the network as
  310.      soon as possible. If the failed workstation did not have files
  311.      open at the time of the failure then other workstations will
  312.      continue to work normally. If it did have files open then any
  313.      workstation which tries to erase one of those files will crash
  314.      with a "File Open on Server" message.
  315.      Any such errors will cease as soon as the failed workstation
  316.      logs back on to the network. If the failure was such that the
  317.      failed workstation cannot be restarted then you must shut down
  318.      and restart the server.
  319.      During most activity in Easy Base, it is unlikely that a
  320.      workstation failure will cause problems. There is one major
  321.      exception to this. That is if a workstation fails while packing
  322.      a form.
  323.      If a workstation fails while packing a form, Easy Base will
  324.      restart the packing process automatically the first time any
  325.      workstation logs on to that data directory. If the failed
  326.      workstation has not logged back in to the network then any
  327.      other workstation logging on to the data directory will crash
  328.      with the "File Open on Server" message. In other words, no
  329.      workstation will be able to access the data directory until
  330.      either the failed workstation is back on the network or the
  331.      network server has been restarted.
  332.      You may also get a "File Open on Server" error if any other
  333.      program such as a fileviewer opens an Easy Base file.
  334.                                 - 9 -
  335. ................................................................................
  336.      Lock Directory                              
  337. Lock Directory
  338.      When you need to make modifications to an application you can
  339.      prevent other workstations from logging on to the directory you
  340.      are about to modify by selecting "Lock Directory" from the
  341.      utilities menu. If any other workstations are active in the
  342.      directory when you select Lock Directory, Easy Base will list
  343.      their terminal numbers on screen. When all other workstations
  344.      have logged out of the directory the lock will engage.
  345.      When you have finished your modifications select "Clear Access
  346.      Locks" to clear the directory lock.
  347.      Apart from application modifications, the directory lock should
  348.      be used before backup, restore or data import routines.
  349.      Once a directory lock has been set, only a workstation using
  350.      the terminal number which set it can access the directory.
  351.                                 - 10 -
  352. ................................................................................
  353.      Numbering Records                           
  354. Numbering Records
  355.      If you are converting a single user application then you may
  356.      have to adjust your code where records are entered via a
  357.      procedure and each record has to have a consecutive number in
  358.      one of its fields.
  359.      In single user applications record numbering is often done by
  360.      having a "Last" form which holds a single record with the last
  361.      record number in it. The procedure which enters new records
  362.      derives the next record number in a field on its input screen
  363.      with the derivation :- Lookup(Last,Number) + 1 and the
  364.      procedure code updates the last form :-
  365.      For Last
  366.         Last.number = input.number
  367.         Update record
  368.      Next
  369.      In a multi user environment this is not reliable. If another
  370.      workstation starts the procedure after yours has done the
  371.      lookup but before you run the procedure then both workstations
  372.      will derive the same number on screen.
  373.      To ensure correct numbering your procedure code must re-check
  374.      the Last.number value when it is run.
  375.      For Last
  376.         input.number = last.number + 1
  377.         Last.number = input.number
  378.         Update record
  379.      next
  380.      Although this will ensure correct numbering, it may be
  381.      off putting to see the same record number on two screens. To
  382.      avoid this you can declare a variable to pick up the number in
  383.      and delete the input.number field. The code would then be:-
  384.      Declare variables
  385.         number as number
  386.      end
  387.      for last
  388.         number = last.number + 1
  389.         Last.number = number
  390.         Update record
  391.      next
  392.      For form new record
  393.         form.number = number
  394.         copy all from input
  395.      next
  396.                                 - 11 -
  397. ................................................................................
  398.      Private Keyword                             
  399. Private Keyword
  400.      One of the main differences between stand alone and multi user
  401.      applications is that where a form is used for temporary storage
  402.      each workstations temporary records must be kept separately.
  403.      For example, in an order taking application you might have one
  404.      procedure which looks up stock items and enters them to an
  405.      "OrderItems" form. When all the items have been entered another
  406.      procedure prints out the order and clears down the "OrderItems"
  407.      form. If these procedures are to be used by more than one work
  408.      station then, clearly, the items entered by one station must be
  409.      stored separately from those entered by another.
  410.      In many data management systems this would involve separate
  411.      forms and procedures for each work station. In Easy Base you
  412.      can separate data by placing the keyword "Private" at the end
  413.      of any for loop and at the end of the "clear records from"
  414.      command.
  415.      In this example the following procedures can be used by any
  416.      number of work stations to create separate orders using the
  417.      same procedures and OrderItems form.
  418.      For OrderItems new record private
  419.         Copy all from input
  420.      Next
  421.      .........................................
  422.      For OrderItems private
  423.         Total = Total + orderitems.price
  424.         print list items
  425.      next
  426.      Print report footer
  427.      .........................................
  428.      Clear records from OrderItems private
  429.      As an aid to debugging you can view the records which have been
  430.      entered privately for any workstation by pressing Ctrl + P when
  431.      in data entry to the form.
  432.      CAUTION
  433.      The provision of private data files is for temporary storage in
  434.      applications like the one described above. It is not suitable
  435.      for keeping permanent private records. There are no facilities
  436.      for packing or reformatting the private data file. Private
  437.      records can only be removed with the "Clear records from form
  438.      private" command in procedure code.  If you modify a form which
  439.      has private data records the private data is not reformatted to
  440.      the new form definition and the old data must be erased with
  441.      the "Clear records from" command before use.
  442.                                 - 12 -
  443. ................................................................................
  444.      Protective Locking                          
  445. Protective Locking
  446.      The Easy Base protective locking allows any number of work
  447.      stations to read or write to data files simultaneously where no
  448.      index file is involved. It allows any number of workstations to
  449.      read via the same index file simultaneously but prevents any
  450.      workstation from writing to an index file that is being read
  451.      from. It prevents simultaneous writing to the same index file
  452.      and any file from being erased while in use.
  453.      Whenever a workstation attempts a process that is locked by
  454.      another work station Easy Base waits for the lock to be
  455.      released. If the lock is not released within four seconds Easy
  456.      Base displays the message "Waiting for Access - Esc Cancel". If
  457.      the user presses the escape key with this message on screen,
  458.      the process is cancelled. If the process was in data entry to a
  459.      form the workstation remains in data entry to that form and is
  460.      ready to accept any other input. If the process was during a
  461.      procedure then the procedure is terminated. If it had a
  462.      repeating input screen, control returns to the input screen and
  463.      if it did not, control returns to the menu from which it was
  464.      called.
  465.      The protective locking routines in Easy Base are automatic
  466.      apart from two options.
  467.      1. In certain procedures you will not wish to allow the user
  468.      the option to cancel the procedure when he has to wait for a
  469.      lock to clear. To do this, place the command "Wait" in the
  470.      procedure code after output field and variable declarations.
  471.      If the command "Wait" has been issued and the procedure
  472.      encounters a lock which lasts more than four seconds then Easy
  473.      Base still displays the message "Waiting for Access" but the
  474.      escape key is not active.
  475.      2. Easy Base provides two options for locking while a procedure
  476.      reads records using an index file. Consider the code:-
  477.      For Customers with Surname in order
  478.         Print list items
  479.      next
  480.      For this procedure to complete successfully, no other work
  481.      station must write to the index file on Surname during the
  482.      procedure. If there are many records in the customers file and
  483.      the output is being sent to a printer then other workstations
  484.      could be prevented from adding modifying or deleting records in
  485.      the customers form for some considerable time.
  486.      As well as reading directly from the Customers.Surname index
  487.      Easy Base can also make a private copy of the index file as it
  488.      stands at the start of the procedure. The Customers form is
  489.      locked only for as long as it takes to make the copy. Once the
  490.                                 - 13 -
  491. ................................................................................
  492.      Protective Locking                          
  493. Protective Locking
  494.      file has been copied, other workstations are free to write to
  495.      the customers form and the procedure selects records using its
  496.      private copy of the index file.
  497.      By default, Easy Base locks the form against write processes
  498.      during the procedure. To take the private index option add the
  499.      command "No Lock" to the end of the "For" line.
  500.      For Customers with surname in order no lock
  501.      There are pros and cons for both methods and the exact nature
  502.      of your application will determine which should be used in any
  503.      given for loop.
  504.      The default system prevents writing to the form for the
  505.      duration of the loop but has no anomalies in the output. The
  506.      copy index method locks the form for the minimum time, but if
  507.      the indexed field of any record is altered by another
  508.      workstation the altered record may be processed out of order.
  509.      For example, in this loop, if another workstation changes a
  510.      customers surname from Smith to Jones before the procedure
  511.      reaches the Smiths, you will have a Jones listed among the
  512.      Smiths in your printout because that is the record's position
  513.      in the private index.
  514.      The "No Lock" option should only be applied to for loops of
  515.      public files. It should not be applied to any loop which is
  516.      already private. :-
  517.      PickList, Temp, any loop using the private keyword and any loop
  518.      using a subindex are automatically private.
  519.      EASY BASE AUTOMATIC LOCKING SUMMARY
  520.      File Erasure (Packing, Clear records from, Rename temp as) :-
  521.      None of these processes will start while any other workstation
  522.      is accessing the form to which they apply. Once they have
  523.      started, no other workstation can access the form until they
  524.      are complete.
  525.      Data Entry to forms :-
  526.      File erasure is not permitted at any stage. Write locking is
  527.      engaged during an F3 search on an indexed field and while any
  528.      other workstation makes a lookup from one of the forms indexed
  529.      fields. Read and write locking is engaged during F2 add or
  530.      update record and during F7 delete record.
  531.      Procedures :-
  532.      In procedures, locks are set separately for each "For" loop.
  533.                                 - 14 -
  534. ................................................................................
  535.      Protective Locking                          
  536. Protective Locking
  537.      When loops are nested, the locks set by each loop are retained
  538.      until the procedure exits the outermost loop when they are all
  539.      cleared together.
  540.      Loops of Picklist, Temp, Subindex and any loop using the
  541.      private keyword have no locking as the files involved are
  542.      private to the workstation.
  543.      Unqualified loops ( For Form ) Lock against file erasure only.
  544.      Loops qualified by "With" set a write lock on the form. Loops
  545.      qualified by "New Record" or containing the commands "Update
  546.      record" or "Delete record" lock the form against read or write.
  547.      A loop prefixed by "Index Off" follows the same rules as for
  548.      Packing. It will not start while any other workstation is
  549.      accessing the form and once started, no other workstation can
  550.      access the form until it is finished and the indexes are
  551.      rebuilt.
  552.                                 - 15 -
  553. ................................................................................
  554.      Self Locking Loops                          
  555. Self Locking Loops
  556.      When For Loops of the same form are nested in a procedure Easy
  557.      Base ignores any lock which the workstation has set for the
  558.      outer loop when it starts the nested one. It does not ignore
  559.      any lock set by another workstation. It is therefor possible to
  560.      write a procedure which cannot be run on two workstations
  561.      simultaneously because they will each lock each other.
  562.      For parts with number = input.number
  563.         for parts alias addone new record
  564.           copy all from parts
  565.           Addone.number = jointext(input.number,"a")
  566.         next
  567.      next
  568.      Although a legitimate procedure in a single user environment,
  569.      this will self lock if run on two workstations. The first line
  570.      sets a read only lock on the parts form. A single workstation
  571.      will ignore its own lock and write the new record but if two
  572.      workstations run the procedure neither will be able to write
  573.      the new record until the other releases its read only lock.
  574.      Such procedures are seldom necessary and when they are you can
  575.      avoid the problem by making the read only lock the inner one.
  576.      For parts new record
  577.         for parts alias getone with number = input.number
  578.            parts.name = getone.name
  579.            parts.Qty = getone.Qty
  580.            parts.number = jointext(input.number,"a")
  581.         next
  582.      next
  583.      Although the convenience of using "Copy all from" has been lost
  584.      this procedure will not self lock. The outer loop now locks
  585.      read and write access to the parts form so any other work
  586.      station attempting to run the same procedure cannot start until
  587.      this one has finished.
  588.                                 - 16 -
  589. ................................................................................
  590.      Strategic Locking                           
  591. Strategic Locking
  592.      Strategic locks are locks which are not covered by the
  593.      automatic protective locking but are none the less necessary
  594.      for the correct operation of an application.
  595.      Strategic locks are set by the procedure command Lock and
  596.      cleared by the command Unlock. Strategic locks will not engage
  597.      while any other workstation is accessing the form to be locked
  598.      and once set prevent any other workstation from accessing the
  599.      form before the Unlock command has been issued.
  600.      Each Lock command must have a matching Unlock command but they
  601.      need not necessarily be in the same procedure. If a form has to
  602.      be locked while several procedures run from a batch menu, for
  603.      example, then the first procedure can lock the form and the
  604.      last can unlock it.
  605.      Strategic locks are seldom required in applications which
  606.      simply store and report on data. In transactional applications
  607.      however, they are often essential.
  608.      As an example, a form "Work" contains records of the hours
  609.      worked by employees - one record for each time each employee
  610.      clocks in. Each record also has a number field and procedures
  611.      which enter records to the form derive the record number field
  612.      from a form "Last" which contains a single record with the last
  613.      record number in form "Work".
  614.      When a single employees records are deleted from the form, the
  615.      form is packed, the records are renumbered and the entry in the
  616.      "Last" form is updated with the new number of records in "Work"
  617.      The Easy Base protective locking will prevent any other work
  618.      station from entering a new record during the deletion loop and
  619.      during the pack. It will not prevent it from entering a new
  620.      record between the deletion loop and the pack or between the
  621.      pack and the updating of the "Last" form. To ensure that no
  622.      other workstation adds a new record to work before the "Last"
  623.      form is updated the "Last" form must be locked throughout.
  624.      Lock Last
  625.      For Work with employee = input.employee
  626.         Delete record
  627.      Next
  628.      Pack Work
  629.      For Last
  630.         For Work
  631.            x = x + 1 : Work.number = x
  632.            Update record
  633.         Next
  634.         Last.number = x : Update Record
  635.      Next
  636.      Unlock Last
  637.                                 - 17 -
  638. ................................................................................
  639.      Terminal Number Val.                        Terminal Number Val.
  640.      The System value "Terminal Number" is available in field
  641.      derivations and procedure code and returns the terminal number
  642.      used to log on to Easy Base.
  643.      The main use of the Terminal Number value is to privatize
  644.      lookups in temporary storage forms. As an example, an invoicing
  645.      system might have one procedure which looks up a customers
  646.      number from the "customers" form and looks up the next invoice
  647.      number from the "last" form. It then enters a record in the
  648.      "current" form so that the next procedure, which looks up stock
  649.      items and enters them privately to the "invoicelines" form, can
  650.      automatically lookup the "Current.Customer" and
  651.      "Current.invoice".
  652.      If multi workstations are to use these procedures at the same
  653.      time then each must be able to lookup its own Current.Customer
  654.      and Current.Invoice. To do this, in say a six terminal
  655.      application, six records are pre entered to the "current" form
  656.      with the values 1,2,3,4,5 and 6 in the terminal field.
  657.      The first procedure has the code:-
  658.      Declare variables
  659.         No as number
  660.      end
  661.      for last
  662.         No = last.invoiceno + 1
  663.         last.invoiceno = No
  664.         Update record
  665.      next
  666.      for current with terminal = terminal number
  667.         current.customer = input.customer
  668.         current.invoiceno = no
  669.         Update record
  670.      Next
  671.      The procedure which enters the invoicelines has a hidden field
  672.      "Terminal" derived :- Terminal Number and looks up the current
  673.      invoice number and customer based on a relationship linking
  674.      this field with the terminal field in the "Current" form.
  675.      The Terminal Number value can also be used to create private
  676.      entries in public forms. If a public form "Notes" has a field
  677.      "Terminal" and each workstation enters its notes together with
  678.      its terminal number then the procedure:
  679.      For Notes with terminal = terminal number
  680.         Print list items
  681.      next
  682.      Will only print the notes entered by the workstation running
  683.      the procedure.
  684.                                 - 18 -
  685. ................................................................................
  686.      Unique Entries                              
  687. Unique Entries
  688.      Where new records are entered to forms via procedures and one
  689.      of the fields in the form must be unique, the procedure must
  690.      test to see if the value it is about to enter in the unique
  691.      field already exists. In single user applications this test can
  692.      be accomplished solely on the input screen.
  693.      To check a unique field "Name" in form Parts the input screen
  694.      name field would be derived:-
  695.      If(lookup(parts,name) = name,blank[beepPart Name Exists !Cursor
  696.      name],name)
  697.      In a multi user environment this is no longer reliable. If two
  698.      workstations enter the same name on their input screens at the
  699.      same time they will both pass the lookup test above. To ensure
  700.      a unique entry you must re check if the value exists at the
  701.      start of the procedure code and return to the input screen if
  702.      the value has been taken since the field was filled.
  703.      Declare variables
  704.         x as number
  705.      end
  706.      For parts new record
  707.         for parts alias checkit with name = input.name
  708.            x = x + 1
  709.         next
  710.         if x > 0 then
  711.            beep
  712.            Display Status "This part name already exists !"
  713.            Delay 2000
  714.            Recall input screen
  715.         end if
  716.         copy all from input
  717.      next
  718.      When the line "For parts new record" is processed, the parts
  719.      form is locked so no other workstation can add a record. If the
  720.      name does not exist then the procedure adds the new record but
  721.      if it does the operator is warned by the beep and status
  722.      display and the procedure returns to the input screen without
  723.      adding the new record.
  724.                                 - 19 -
  725. ................................................................................
  726.